<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../static/css/admin.css" media="all">
    <style>
        .layui-form-label{
            width: 100px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header" style="border-radius: 0;border-top: 4px solid #d2d2d2;">
            <div>简历管理>简历登记</div>
        </div>
        <div class="layui-form layui-card-body layuiadmin-card-header-auto" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">应聘职位名称</label>
                <div class="layui-input-inline">
                    <select name="job_name" id="job_name" lay-verify="required" lay-filter="job-name">
                        <option value=""></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">应聘职位编码</label>
                <div class="layui-input-inline">
                    <input type="text" id="job_id" name="job_id" lay-verify="required" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">应聘职位分类</label>
                <div class="layui-input-inline">
                    <input type="text" id="job_type" name="job_type" lay-verify="required" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <select name="sex">
                        <option value="1" selected>男</option>
                        <option value="0">女</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">招聘类型</label>
                <div class="layui-input-inline">
                    <select name="recruit_type">
                        <option value="社会招聘">社会招聘</option>
                        <option value="校园招聘">校园招聘</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">EMAIL</label>
                <div class="layui-input-inline">
                    <input type="text" name="email" lay-verify="required" autocomplete="off" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">户口所在地</label>
                <div class="layui-input-inline">
                    <input type="text" name="location" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline"  style="width: 664px">
                <label class="layui-form-label">住址</label>
                <div class="layui-input-inline">
                    <input type="text" name="address" lay-verify="required" autocomplete="off" class="layui-input" style="width: 525px" >
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">政治面貌</label>
                <div class="layui-input-inline">
                    <select name="politic_outlook" lay-verify="required">
                        <option value=""></option>
                        <option value="党员">党员</option>
                        <option value="团员">团员</option>
                        <option value="群众">群众</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">身份证号</label>
                <div class="layui-input-inline">
                    <input type="text" name="identity" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">毕业院校</label>
                <div class="layui-input-inline">
                    <input type="text" name="graduate_school" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">学历</label>
                <div class="layui-input-inline">
                    <input type="text" name="degree" lay-verify="required" autocomplete="off" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">专业</label>
                <div class="layui-input-inline">
                    <input type="text" name="major" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">工作经验</label>
                <div class="layui-input-inline">
                    <input type="text" name="experience" lay-verify="required" autocomplete="off" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">薪资要求</label>
                <div class="layui-input-inline">
                    <input type="text" name="salary" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">是否在职</label>
                <div class="layui-input-inline">
                    <select name="is_work" lay-verify="required">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">是否应届生</label>
                <div class="layui-input-inline">
                    <select name="is_graduate" lay-verify="required">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline">
                <label class="layui-form-label">登记时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="reg_time" name="reg_time" lay-verify="required" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">个人履历</label>
                <div class="layui-input-block" style="width: 860px; margin-left: 130px">
                    <textarea name="resumes" placeholder="请输入内容" class="layui-textarea" style="height: 180px;" ></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">简历附件</label>
                <div class="layui-input-inline">
                    <input type="text" name="resume_url" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-input-inline layui-hide" >
                <label class="layui-form-label">是否推荐面试</label>
                <div class="layui-input-inline">
                    <select name="is_recom">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline layui-hide">
                <label class="layui-form-label">推荐人</label>
                <div class="layui-input-inline">
                    <input type="text" id="recommender" name="recommender" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item layui-input-inline layui-hide">
                <label class="layui-form-label">推荐时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="recom_time" name="recom_time" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item layui-form-text layui-hide">
                <label class="layui-form-label">推荐面试意见</label>
                <div class="layui-input-block" style="width: 860px; margin-left: 130px">
                    <textarea name="recom_advice" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item layui-input-block" style="margin-left: 420px">
                <button type="submit" class="layui-btn" lay-submit lay-filter="LAY-user-front-submit" style="margin-left: 40px;margin-right: 30px">登记</button>
                <button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="back">返回</button>
            </div>
        </div>
    </div>
</div>

<!--<script src="js/jquery-2.0.3.min.js"></script>-->
<script src="../../../static/layui/layui.js"></script>
<script type="text/javascript">
    // 日期格式转换函数
    function formatDate(str) {
        if(str != null){
            var now = new Date(str);
            var year = now.getFullYear();  //取得4位数的年份
            var month = now.getMonth() + 1;  //取得日期中的月份，其中0表示1月，11表示12月
            var date = now.getDate();      //返回日期月份中的天数（1到31）
            return year + "-" + month + "-" + date;
        }
        return "";
    }
</script>
<script type="text/javascript">

    layui.use(['layer','table','form','element','util','laydate'], function(){
        var $ = layui.$
            ,form = layui.form
            ,layer = layui.layer
            ,table = layui.table
            ,element = layui.element
            ,util = layui.util
            ,laydate = layui.laydate;

        var userInfo = sessionStorage.getItem("user");
        var user = JSON.parse(userInfo);
        var jobList;
        $(document).ready(function(){
            var currentDate = new Date();
            var year = currentDate.getFullYear();  //取得4位数的年份
            var month = currentDate.getMonth() + 1;  //取得日期中的月份，其中0表示1月，11表示12月
            var date = currentDate.getDate();      //返回日期月份中的天数（1到31）
            document.getElementById("reg_time").value = year + "-" + month + "-" + date;
            document.getElementById("reg_time").setAttribute("readonly","readonly");
            //获取职位名称
            $.ajax({
                url:"/recruit/getJobName",
                type:"post",
                data:{},
                dataType:"json",
                success:function (res){
                    //console.log("res.data------")
                    //console.log(res.data)
                    jobList=res.data;
                    //console.log("datas.data------")
                    //console.log(datas.data);
                    //console.log(res.code)
                    if(res.code == 0){
                        let selectElement=document.getElementById("job_name");

                        for(let i=0;i<res.data.length;i++){
                            let optionElement = document.createElement("option");
                            optionElement.text=res.data[i].job_name;
                            optionElement.value=res.data[i].job_name;
                            selectElement.add(optionElement);
                            //console.log(selectElement);
                        }
                        form.render();
                    }
                },error:function (res){

                }
            })
        })

        var active = {
            /*add: function(){
                window.location.href = "addJobPost.html"
            }*/
            back: function () {
                window.location.href = "resumeList.html"
            }
        };

        //监听下拉框选中事件
        form.on('select(job-name)',function (data){
            for (let i = 0; i<jobList.length; i++){
                if(data.value === jobList[i].job_name){
                    document.getElementById("job_id").value = jobList[i].job_id;
                    document.getElementById("job_type").value = jobList[i].job_type;
                    break;
                }
            }
        })

        form.on('submit(LAY-user-front-submit)',function (data){
            var field = data.field;
            //console.log(field)
            $.ajax({
                url:"/recruit/resume/addResume", //请求后端接口地址
                type:"post", //请求方式get | post
                data:JSON.stringify(field), //提交json字符串对象参数
                contentType:"application/json;charset=utf-8", //发送信息至服务器时内容编码类型
                dataType:"json", //后端返回参数类型
                success:function (res){ //请求成功后回调函数res = JSONObject.toJSONString(resultMap)
                    if(res.code == 0){//成功
                        layer.msg(res.msg);//弹出提示
                        //table.reload('LAY-user-manage'); //数据刷新
                        //window.setTimeout("window.layui.href = 'job_post.html'",3000)
                    }
                    if(res.code == -1){//系统出问题
                        layer.msg(res.msg,{icon: 5});//弹出提示
                    }
                }
            })
        });

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        /*时间选择*/

    });
</script>

</body>
</html>